﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;

namespace DAO
{
    public class NhanVienDAO
    {
        // 0712455
        public static int LayChiNhanhGD(string MaNV)
        {
            SqlConnection cnn = KetNoiCSDL.TaoKetNoi();
            string query = String.Format("select * from Nhan_Vien where MaNV = '{0}'", MaNV);
            SqlCommand cmd = new SqlCommand(query, cnn);

            cnn.Open();
            try
            {
                SqlDataReader dr = cmd.ExecuteReader();
                int CNGiaoDich = -1;
                if(dr.Read())
                {
                    CNGiaoDich = (int)dr["MaChiNhanh"];
                }
                cnn.Close();
                return CNGiaoDich;

            }
            catch (Exception ex)
            {
                if (cnn.State == ConnectionState.Open)
                    cnn.Close();
                throw ex;
            }
        }
    }
}
